package hypeerweb;

import states.NodeState;

public class SurrogateNeighbor extends StandardNodeRole {

	public SurrogateNeighbor(int id) {
		super(id);
	}
	
	public SurrogateNeighbor(int id, int height)
	{
		super(id, height);
	}

	@Override
	public void AddMe(Node upPointer) {
		
		int parentID = upPointer.getWebId().getParentsValue();
		Node parent = new Node(parentID);
		
		Connections connections = delegate.getConnections();

		connections.addUpPointer(upPointer);

		connections.receivedChild(parent);

		delegate.setState(NodeState.UpPointingNodeState);
		
	}

	@Override
	public void ReplaceMe(Node node) {
		Connections connections = delegate.getConnections();
		
		connections.updateUpPointer(node);

	}

	@Override
	public void DeleteMe(Node node) {
		Connections connections = delegate.getConnections();
		
		connections.removeUpPointer(node);
	}

}
